﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    public class KeChengDAL
    {
        /// <summary>
        /// 查询整张表
        /// </summary>
        /// <returns>返回list泛型集合</returns>
        public static List<KeCheng> Select()
        {
            string sql = "select * from KeCheng";
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            List<KeCheng> list = new List<KeCheng>();
            foreach (DataRow item in dt.Rows)
            {
                KeCheng model = new KeCheng();
                model.KeChengID =Convert.ToInt32(item["KeChengID"]);
                model.KeChengImages = item["KeChengImages"].ToString();
                model.KeChengName = item["KeChengName"].ToString();
                model.KeChengPrice = Convert.ToDecimal(item["KeChengPrice"]);
                model.KeChengTuanjia = Convert.ToDecimal(item["KeChengTuanjia"]);
                model.KeChengTypeID = Convert.ToInt32(item["KeChengTypeID"]);
                list.Add(model);
            }
            return list;
        }
       
        /// <summary>
        /// 查询VIP的课程
        /// </summary>
        /// <returns>返回list泛型集合</returns>
        public static List<KeCheng> SelectVip()
        {
            string sql = "select * from KeCheng where KeChengPrice>0";
            DataTable dt = DBHelper.Instance().GetDataTableBySql(sql);
            List<KeCheng> list = new List<KeCheng>();
            foreach (DataRow item in dt.Rows)
            {
                KeCheng model = new KeCheng();
                model.KeChengID = Convert.ToInt32(item["KeChengID"]);
                model.KeChengImages = item["KeChengImages"].ToString();
                model.KeChengName = item["KeChengName"].ToString();
                model.KeChengPrice = Convert.ToDecimal(item["KeChengPrice"]);
                model.KeChengTuanjia = Convert.ToDecimal(item["KeChengTuanjia"]);
                model.KeChengTypeID = Convert.ToInt32(item["KeChengTypeID"]);
                list.Add(model);
            }
            return list;
        }
    }
}
